local key = KEYS[1]
local subKey = KEYS[2]
local deductCnt = KEYS[3] or 1
redis.log(redis.LOG_NOTICE,"key = ",key,", subKey = ",subKey,", deductCnt = ",deductCnt)
local val = redis.call("HGET", key,subKey);
if type(val) == "string" then
    val = tonumber(val)
end
redis.log(redis.LOG_NOTICE,"val = ",val)
redis.log(redis.LOG_NOTICE,type(val),type(deductCnt))
if val >= deductCnt then
    redis.call("HSET",key,subKey,val-deductCnt)
    return val-deductCnt
else
    return -1
end